home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / include / wcesock.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  2.8 KB  |  98 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #ifndef __WCESOCK_H__
  12. #define __WCESOCK_H__
  13.  
  14.  
  15. // WM_SOCKET_NOTIFY and WM_SOCKET_DEAD are used internally by MFC's
  16. // Windows sockets implementation.  For more information, see sockcore.cpp
  17. #undef  WM_SOCKET_NOTIFY
  18. #define WM_SOCKET_NOTIFY    0x0373   // defined in AFXPRIV.H
  19.  
  20. // Special global function to return the socket window belonging to the
  21. // thread state.
  22. HWND AfxGetCeSocketWindow();
  23.  
  24. //////////////////////////////////////////////////////////////////////////
  25. //
  26. class CCeSocket : public CSocket
  27. {
  28.     DECLARE_DYNAMIC(CCeSocket);
  29.  
  30. public:
  31.     enum PURPOSE_E {FOR_LISTENING=0, FOR_DATA=1};
  32.  
  33. private:
  34.     void   BeginThread( PURPOSE_E iPurpose=FOR_LISTENING );
  35.     void   EndThreads();
  36.  
  37.     BOOL   IsAlive();
  38.     BOOL   IsListening();
  39.     BOOL   IsReadReady();
  40.     BOOL   SetForRead();
  41.     BOOL   SetForWrite();
  42.     BOOL   SetForReadnWrite();
  43.     BOOL   DoAccept();
  44.     BOOL   DoConnect();
  45.     BOOL   DoRead();
  46.  
  47. private:
  48.     BOOL   SetNonblocking();
  49.     BOOL   SetBlocking();
  50.  
  51. private:
  52.     fd_set             m_ReadFds;
  53.     fd_set             m_WriteFds;
  54.     static CWinThread* m_pListenThread;
  55.     static CWinThread* m_pDataThread;
  56.     static int         m_iSocketCount;
  57.     PURPOSE_E          m_iPurpose;
  58.     BOOL               m_bQuit;
  59.     BOOL               m_bConnectCalled;
  60.     BOOL               m_bIsConnected;
  61.  
  62. public:
  63.     CCeSocket( PURPOSE_E iPurpose=FOR_DATA );
  64.     virtual ~CCeSocket();
  65.     virtual BOOL Create( UINT nSocketPort=0 );
  66.  
  67.     // Overridable callbacks
  68.     virtual void OnAccept( int nErrorCode )
  69.         { CSocket::OnAccept(nErrorCode); }
  70.     virtual void OnConnect( int nErrorCode )
  71.         { CSocket::OnConnect(nErrorCode); }
  72.     virtual BOOL ConnectHelper(const SOCKADDR* lpSockAddr, int nSockAddrLen);
  73.  
  74.     // Friends
  75.     friend unsigned int  AFX_CDECL ListenThread( void* pvParams );
  76.     friend unsigned int  AFX_CDECL DataThread( void* pvParams );
  77.  
  78.     friend class CSocket;
  79. };
  80.  
  81.  
  82. // Although WinCE 2.10 implements WSAStartup() and WCECleanup() as API's, we define them as macros for backward
  83. // compatibility.
  84.  
  85. #undef WSAStartup
  86. #define WSAStartup(wVersionRequired,lpWSAData)    \
  87.         ((lpWSAData)->wVersion=wVersionRequired,\
  88.         (lpWSAData)->wHighVersion=wVersionRequired,\
  89.         (lpWSAData)->szDescription[0]='\0',\
  90.         (lpWSAData)->szSystemStatus[0]='\0',\
  91.         (lpWSAData)->iMaxSockets=10,\
  92.         (lpWSAData)->iMaxUdpDg=0,\
  93.         (lpWSAData)->lpVendorInfo=NULL,(0))
  94. #undef WSACleanup
  95. #define WSACleanup()            (0)
  96.  
  97. #endif // __WCESOCK_H__
  98.